package Homework.Top1.Test3;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.*;

public class MapPet {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        Map<String,String> pet=new HashMap<>();
        pet.put("猫","cat");
        pet.put("狗","dog");
        pet.put("鱼","fish");
        for (String s : pet.keySet()) {
            String value=pet.get(s);
            System.out.println(s+value);
        }
        int pos=0;
        System.out.println("请输入中文查找项：");
        String p=in.next();
        Set<Map.Entry<String,String>> entries=pet.entrySet();
        for (Map.Entry<String,String> a:entries){
            if (a.getKey().equals(p)){
                pos++;
            }
        }
        if (pos==1){
            System.out.println("已找到");
        }else{
            System.out.println("未找到");
        }
            pos=0;
        System.out.println("请输入英文查找项：");
        String p1=in.next();
        Set<Map.Entry<String,String>> entries1=pet.entrySet();
        for (Map.Entry<String,String> a:entries1){
            if (a.getValue().equals(p1)){
                pos++;
            }
        }
        if (pos==1){
            System.out.println("已找到");
        }else{
            System.out.println("未找到");
        }
    }
}
